<?php
/**
 * Eren Framework
 * 
 * Base Controller,all controller must inherit from this
 * 
 * @category System
 * @author Manu Soros Leu
 * @copyright manusoros@gmail.com
 */

class Eren_Controller
{

    /**
     * This function will be execute before Action
     */
    public function init(){}
    
    /**
     * Get Param from $_GET
     * 
     * @param string $key
     * @param string $default
     * @return string
     */
    public function getParam($key, $default = NULL)
    {
        return Eren_Request_Param::getInstance()->getParam($key, $default);
    }
    
    /**
     * Get All Param from $_GET
     * 
     * @return array
     */
    public function getParams()
    {
        return Eren_Request_Param::getInstance()->getParams();
    }
    
    /**
     * Get Param from $_POST
     * 
     * @param string $key
     * @param string $default
     * @return string
     */
    public function getPost($key, $default = NULL)
    {
        return Eren_Request_Param::getInstance()->getPost($key, $default);
    }
    
    /**
     * Get All Param from $_POST
     * 
     * @return array
     */
    public function getPosts()
    {
        return Eren_Request_Param::getInstance()->getPosts();
    }
    
    /**
     * Render data to the view tpl
     * 
     * @param string $key
     * @param int|string|array $value
     */
    public function setData($key, $value)
    {
        Eren_View::getInstance()->setData($key, $value);
    }
    
    /**
     * Set the path of view tpl
     * 
     * @param string $file
     */
    public function setView($file)
    {
        Eren_View::getInstance()->setView($file);
    }
    
    /**
     * Forward,Redirect
     * 
     * @param string $url
     */
    public function forward($url)
    {
        Eren_Registry::set("FORWARD", $url);
    }
}